package com.itheima.day14;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Practice3 {
    public static void main(String[] args) {
        ArrayList<Student1> students = new ArrayList<>();
        Scanner sc = new Scanner(System.in);

        for (int i = 0; i < 3; i++) {
            System.out.println("请输入第"+(i+1)+"位学生的姓名：");
            String name = sc.next();
            System.out.println("语文成绩：");
            int yu = sc.nextInt();
            System.out.println("数学成绩：");
            int shu = sc.nextInt();
            System.out.println("英语成绩：");
            int ying = sc.nextInt();
            Student1 s1 = new Student1(name,yu,shu,ying);
            students.add(s1);
        }
        //System.out.println(students);

        try(FileWriter fw = new FileWriter("D:\\code\\javaee156\\javaeezuoye\\src\\com\\itheima\\day14\\score.txt");
            BufferedWriter bw = new BufferedWriter(fw);
        ) {
            for (int i = 0; i < 3; i++) {
                String s = students.get(i).toString();
                bw.write(s);
                 bw.newLine();
                System.out.println(s);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

class Student1 {
    private String name;
    private int yu;
    private int shu;
    private int ying;

    public Student1() {
    }

    public Student1(String name, int yu, int shu, int ying) {
        this.name = name;
        this.yu = yu;
        this.shu = shu;
        this.ying = ying;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYu() {
        return yu;
    }

    public void setYu(int yu) {
        this.yu = yu;
    }

    public int getShu() {
        return shu;
    }

    public void setShu(int shu) {
        this.shu = shu;
    }

    public int getYing() {
        return ying;
    }

    public void setYing(int ying) {
        this.ying = ying;
    }

    @Override
    public String toString() {
        return
                name +":"
                        +yu +","+
                        shu +","+
                        ying
                ;
    }
}